#include "settingpagetitle.h"
#include <QHBoxLayout>
#include <QApplication>

SettingPageTitle::SettingPageTitle(QWidget *parent)
    : QWidget(parent)
{
    s_pFuncLabel = new QLabel(this);
    //sIcon = new QLabel(this);
    sIcon = new QPushButton(this);
    s_pCloseButton = new QPushButton(this);

    s_pCloseButton->setProperty("isWindowButton", 0x2);
    s_pCloseButton->setProperty("useIconHighlightEffect",0x8);
    s_pCloseButton->setFlat(true);


    s_pFuncLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    sIcon->setFixedSize(26,26);
    s_pCloseButton->setFixedSize(30,30);

    s_pFuncLabel->setObjectName("whiteLabel");
    s_pCloseButton->setObjectName("closeButton");

    QHBoxLayout *sLayout = new QHBoxLayout(this);
    sLayout->addWidget(sIcon);
    sLayout->addSpacing(8);
    sLayout->addWidget(s_pFuncLabel);
    sLayout->addStretch();
    sLayout->addWidget(s_pCloseButton);
    sLayout->setSpacing(0);
    sLayout->setContentsMargins(0,0,0,0);

    s_pFuncLabel->setText(tr("Camera"));
    //sIcon->setPixmap(QPixmap::fromImage(QImage(":/image/camera-app@2x.png")));
    sIcon->setIcon(QIcon::fromTheme("kylin-camera"));
    sIcon->setIconSize(QSize(26,26));
    s_pCloseButton->setIcon(QIcon::fromTheme("window-close-symbolic"));

    this->setFixedHeight(30);
    this->setLayout(sLayout);

    connect(s_pCloseButton,&QPushButton::clicked,this,&SettingPageTitle::closeButton);

}

void SettingPageTitle::closeButton(){
    this->window()->close();

}
